<?php /* УТФ-8:fix */

class SPImodel__songnvideo__front extends SPImodel__songnvideo
{
    public function select( $type, $limit = null, $mode='' )
    {
        $limit = (int) $limit;
		
		switch ($mode) 
		{
			case 'tophits':
				$workstatus = "workstatus = 1";
			break;
			
			case 'novelty':
				$workstatus = "workstatus = 2";
			break;
			
			case '':
				$workstatus = "workstatus = 1";
			break;
		}

        $query =    " SELECT * "
               .      " FROM ".SPIcfg::$store['table:content']
               .     " WHERE type = '".addslashes($type)."' "
               .       " AND "
			   .  $workstatus 
               .  " ORDER BY order_index ASC, id DESC "
               . ( $limit ? " LIMIT {$limit} " : '' )
               ;

        return SPIstore::I()->query( $query );
    }
}
